package com.atguigu.day01

import org.apache.flink.streaming.api.scala.{StreamExecutionEnvironment, createTypeInformation}

object Example1 {
  def main(args: Array[String]): Unit = {
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1)

    val intDataStream = env.fromElements("hello world","hello scala","hello flink")
    intDataStream
      .flatMap(_.split(" ").map((_,1)))
      .keyBy(0)
      .reduce((x,y)=>(x._1,y._2+x._2))
      .print()
    env.execute()
  }

}
